<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<script type="text/javascript">
			function jisuan() {
				
				var fi = prompt("请输入科目数量", "");
				var zong=0;
		var bo=true;
				if(panduan(fi)) {
					document.write("输入不是数字");
return;
				} else {
					if(panduan1(fi)) {
						for(var i = 1; i <= parseInt(fi); i++) {
							var fn = prompt("请输入第" + i  + "科目分数", "");
							if(panduan(fn)) {
								document.write("输入不是数字");
								bo=false;
								break;
							} else {
								if(panduan1(fn)) {
									zong = parseInt(fn) + zong;

								} else {
									document.write("输入不能是负数");
								bo=false;
									
									break;}
								}
								}

							} else {
								document.write("输入不能是负数");
return;
							}

						}
				if(bo){
document.writeln(fi+"门总成绩为"+zong)	
}
					}

				

			

			function panduan(coon) {
				var fi = parseInt(coon);
				var fi = parseInt(coon);
				return isNaN(fi);
			}

			function panduan1(num) {
				var fi = parseInt(num);
				if(fi > 0) {
					return true;
				}
				return false;
			}
		</script>
		<input onclick="jisuan()" type="button" value="统计成绩" name="tonji" />
	</body>

</html>